
// ***********************************************************************
// AUTO GENERATED CLASS - Do Not Modify this file, if needed modify .tt
// ***********************************************************************
// Assembly         : InnovaApp_DomainLayer
// Author           : LJO+01
// Created          : 17/11/2013 20:29:50
// ***********************************************************************
// <copyright file="N.A." company="Copyright © Innovacall 2011">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary>
// Domain layer  
// DomainClass
// </summary>
// ***********************************************************************

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;


namespace InnovaApp.Layers.DomainLayer
{
    /// <summary>
    /// Class Language
    /// </summary>
    [Serializable]
    public partial class Language : _DomainLayer_Base  
    {
        #region Primitive Properties
    	
        /// <summary>
        /// Gets or sets Id.
        /// </summary>
        /// <value>The Id.</value>
        public virtual int Id
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Name.
        /// </summary>
        /// <value>The Name.</value>
        public virtual string Name
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets Description.
        /// </summary>
        /// <value>The Description.</value>
        public virtual string Description
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets SortIndex.
        /// </summary>
        /// <value>The SortIndex.</value>
        public virtual int SortIndex
        {
            get;
            set;
        }
    	
        /// <summary>
        /// Gets or sets rowversion.
        /// </summary>
        /// <value>The rowversion.</value>
        public virtual byte[] rowversion
        {
            get;
            set;
        }

        #endregion

        #region Navigation Properties
    
        /// <summary>
        /// Link Language to all Contact
        /// </summary>
        public virtual ICollection<Contact> Contact
        {
            get
            {
                if (_contact == null)
                {
                    var newCollection = new FixupCollection<Contact>();
                    newCollection.CollectionChanged += FixupContact;
                    _contact = newCollection;
                }
                return _contact;
            }
            set
            {
                if (!ReferenceEquals(_contact, value))
                {
                    var previousValue = _contact as FixupCollection<Contact>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupContact;
                    }
                    _contact = value;
                    var newValue = value as FixupCollection<Contact>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupContact;
                    }
                }
            }
        }
        private ICollection<Contact> _contact;
    
        /// <summary>
        /// Link Language to all LayoutMenu_Translation
        /// </summary>
        public virtual ICollection<LayoutMenu_Translation> LayoutMenu_Translation
        {
            get
            {
                if (_layoutMenu_Translation == null)
                {
                    var newCollection = new FixupCollection<LayoutMenu_Translation>();
                    newCollection.CollectionChanged += FixupLayoutMenu_Translation;
                    _layoutMenu_Translation = newCollection;
                }
                return _layoutMenu_Translation;
            }
            set
            {
                if (!ReferenceEquals(_layoutMenu_Translation, value))
                {
                    var previousValue = _layoutMenu_Translation as FixupCollection<LayoutMenu_Translation>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupLayoutMenu_Translation;
                    }
                    _layoutMenu_Translation = value;
                    var newValue = value as FixupCollection<LayoutMenu_Translation>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupLayoutMenu_Translation;
                    }
                }
            }
        }
        private ICollection<LayoutMenu_Translation> _layoutMenu_Translation;
    
        /// <summary>
        /// Link Language to all InnoAppSpecialBlockHTMLContent
        /// </summary>
        public virtual ICollection<InnoAppSpecialBlockHTMLContent> InnoAppSpecialBlockHTMLContent
        {
            get
            {
                if (_innoAppSpecialBlockHTMLContent == null)
                {
                    var newCollection = new FixupCollection<InnoAppSpecialBlockHTMLContent>();
                    newCollection.CollectionChanged += FixupInnoAppSpecialBlockHTMLContent;
                    _innoAppSpecialBlockHTMLContent = newCollection;
                }
                return _innoAppSpecialBlockHTMLContent;
            }
            set
            {
                if (!ReferenceEquals(_innoAppSpecialBlockHTMLContent, value))
                {
                    var previousValue = _innoAppSpecialBlockHTMLContent as FixupCollection<InnoAppSpecialBlockHTMLContent>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupInnoAppSpecialBlockHTMLContent;
                    }
                    _innoAppSpecialBlockHTMLContent = value;
                    var newValue = value as FixupCollection<InnoAppSpecialBlockHTMLContent>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupInnoAppSpecialBlockHTMLContent;
                    }
                }
            }
        }
        private ICollection<InnoAppSpecialBlockHTMLContent> _innoAppSpecialBlockHTMLContent;

        #endregion

        #region Association Fixup
    
        private void FixupContact(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (Contact item in e.NewItems)
                {
                    item.Language = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (Contact item in e.OldItems)
                {
                    if (ReferenceEquals(item.Language, this))
                    {
                        item.Language = null;
                    }
                }
            }
        }
    
        private void FixupLayoutMenu_Translation(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (LayoutMenu_Translation item in e.NewItems)
                {
                    item.Language = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (LayoutMenu_Translation item in e.OldItems)
                {
                    if (ReferenceEquals(item.Language, this))
                    {
                        item.Language = null;
                    }
                }
            }
        }
    
        private void FixupInnoAppSpecialBlockHTMLContent(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (InnoAppSpecialBlockHTMLContent item in e.NewItems)
                {
                    item.Language = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (InnoAppSpecialBlockHTMLContent item in e.OldItems)
                {
                    if (ReferenceEquals(item.Language, this))
                    {
                        item.Language = null;
                    }
                }
            }
        }

        #endregion

    }
}
